package com.bjpowerrnode.javase.array.homework;
/*
酒店的房间
 */
public class Room {

    private int no;//房间编号
    private String type;//房间类型
    private boolean status;//房间状态

    //构造方法
    public Room() {
    }

    public Room(int no, String type, boolean status) {
        this.no = no;
        this.type = type;
        this.status = status;
    }

    //setter and getter 方法
    public void setNo(int no){
        this.no = no;
    }

    public int getNo(){
        return no;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    //IDEA工具对boolean类型的变量，生成的get方法的方法名是：isXXX()
    //如果不喜欢可以修改为get
    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    //equals()方法重写
    //equals()方法是用来比较两个对象是否相同的，至于怎么比较这个需要程序员怎么比较。
    public boolean equals(Object obj){
        if(obj == null || !(obj instanceof Room)) return false;
        if(this == obj) return true;
        Room room = (Room) obj;
//        if(this.no == room.no ) return true;
//        return false;
        return this.no == room.no;
    }
    //toString()方法重写
    //toString()方法的目的就是将就java对象转换为字符串，怎么转自己定义。
    public String toString(){
        return "[" + no + "," + type + "," + (status? "空闲" : "占用") +  "]";
    }

/*    //测试
    public static void main(String[] args) {
        Room room = new Room(101,"单人房",false);
        Room room1 = new Room(101,"单人房",false);
        System.out.println(room.equals(room1));
        //room是一个引用，println(引用)，会自动调用引用的toString()方法。
       // System.out.println(room.toString());
        System.out.println(room);
    }*/
}
